package com.fei.fpmall.malladmin.interceptor;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fei.fpmall.common.utils.UserUtil;
import com.fei.fpmall.core.interceptor.FeiInterceptor;
import com.fei.fpmall.entity.basemanage.User;



/**
 * 
 */
public class MallAdminLoginInterceptor implements FeiInterceptor {

    @Override
    public boolean interceptor(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object handler) throws Exception {
    	User loginAdmin = UserUtil.getLoginUser(httpServletRequest);
    	//没登录的都先跳转到登录界面
        if (loginAdmin == null) { 
        	String redirectUrl=httpServletRequest.getContextPath()+ "/account/login";
        	System.out.println(redirectUrl);
            httpServletResponse.sendRedirect(redirectUrl);
            return false;
        }
        return true;
        
    }
}
